<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('薪资开启纠错添加员工')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: datetimepicker-js"/>


<script th:inline="javascript">
    var prefix = ctx + "salaryOpen/salaryOpen";
    var pgid;
    var Bgdate;
    var EDdate;
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        var map = [[${map}]];
        pgid = map.id;
        Bgdate = map.Bgdate;
        EDdate = map.EDdate;

        getData();
    });

    function getData() {
        var columns = [];
        var other;
        var check = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compname = {field: 'compname', title: '公司名称'};
        var departname = {field: 'departname', title: '部门名称'};
        var jobname = {field: 'jobname', title: '工作岗位'};
        var empStatusName = {field: 'empStatusName', title: '员工状态'};
        var joinDate = {field: 'joinDate', title: '入职日期'};
        var pzidName = {field: 'pzidName', title: '薪资区域'};
        var effectDate = {field: 'effectDate', title: '起薪日期'};
        var initialiZed = {
            field: 'initialiZed', title: '？确认',
            formatter: function (value, row, index) {
                if (row.initialiZed == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }
        };
        var initialiZedByName = {field: 'initialiZedByName', title: '确认人'};
        var initialiZedTime = {field: 'initialiZedTime', title: '确认时间'};

        var closed = {
            field: 'closed', title: '？封存',
            formatter: function (value, row, index) {
                if (row.initialiZed == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }
        };
        var closedByName = {field: 'closedByName', title: '封存人'};
        var closedtime = {field: 'closedtime', title: '封存时间'};

        columns.push(check, id, badge, name, compname, departname, jobname, empStatusName, joinDate, pzidName);
        columns.push(effectDate, initialiZed, initialiZedByName, initialiZedTime, closed, closedByName, closedtime);


        $.ajax({
            async: false,
            url: ctx + "salaryAdmin/findProByPgid",
            data: {"pgid": pgid},
            type: "post",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    other = {
                        field: data[i], title: data[i]
                    }
                    columns.push(other);
                }
                var options = {
                    code: "id",
                    uniqueId: "id",
                    pagination: false,
                    url: prefix + "/listHistory?pgid=" + pgid + "&Bgdate=" + Bgdate + "&EDdate=" + EDdate,
                    height: $(window).height() - 120,
                    modalName: "薪资开启",
                    columns: columns
                };
                $.table.init(options);
            },
        });
        $.table.init(options);

    }

    function submitHandler() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        var num = 0;
        var allid = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要调岗的人员");
            return;
        }
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allid += row[i].id
            } else {
                allid += row[i].id + ","
            }
        }

        $.ajax({
            url: ctx + "SalaryOpenCorrection/SalaryOpenCorrection/cstaffAdd2",
            data: {
                "allid": allid
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                $.operate.successCallback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }

</script>


</body>
</html>